function xhpr = getExpectedExcessReturns_h1(model,theta2,x,z)

nx    = size(model.gx,2);
[h0_1,h0_2,hx_1,hx_2,sigma] = unfoldTheta2_threshold_macro(theta2,nx);

% Conditional expectations of the states
if z >= 0
    Ex = (h0_1+hx_1*x);
elseif z < 0
    Ex = (h0_2+hx_2*x);
end
% Conditional second moment
Exx = sigma*sigma' + Ex*Ex';

% Conditional holding period return
hpr = nan(length(model.A),1);
% for k=2:length(model.A)
%     hpr_loop(k,1) = - model.A(1,k)  - model.B(:,k)'*x    - reshape(model.C(:,:,k),1,nx^2)*kron(x,x) ...
%                + model.A(1,k-1)+ model.B(:,k-1)'*Ex + reshape(model.C(:,:,k-1),1,nx^2)*Exx(:);
% end
hpr(2:end,1) = - model.A(1,2:end)'  - model.B(:,2:end)'*x    - model.vecC(2:end,:)*kron(x,x) ...
               + model.A(1,1:end-1)'+ model.B(:,1:end-1)'*Ex + model.vecC(1:end-1,:)*Exx(:);

% the short rate
r = (model.r0 + model.rx*x + model.rxx*kron(x,x))/12;

% Conditional excess holding period return (monthly)
xhpr = hpr - r;
end